
import threading
import time


def eat():
    this_thread = threading.currentThread()
    for i in range(1, 5):
        print("%s 吃面条" % this_thread.name)
        time.sleep(1)


def drink():
    this_thread = threading.currentThread()
    for y in range(1, 5):
        print("%s 喝汤" % this_thread.name)
        time.sleep(1)
# 多线程


def multi_threading():
    th1 = threading.Thread(target=eat, name='线程1')
    th2 = threading.Thread(target=drink, name='线程2')
    th1.start()
    th2.start()
    print("多线程")

# 单线程


def single_threading():
    eat()
    drink()
    print("单线程")


if __name__ == '__main__':
    # MainThread 吃面条
    # MainThread 吃面条
    # MainThread 吃面条
    # MainThread 吃面条
    # MainThread 喝汤
    # MainThread 喝汤
    # MainThread 喝汤
    # MainThread 喝汤
    # 单线程
    # single_threading()

    #  线程1 吃面条
    # 线程2 喝汤
    # 多线程
    # 线程1 吃面条
    # 线程2 喝汤
    # 线程2 喝汤
    # 线程1 吃面条
    # 线程1 吃面条
    # 线程2 喝汤
    multi_threading()
